package com.smartwebx.ha.dal.usebean;

import java.io.Serializable;
import java.text.ParseException;
import java.util.Date;

import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateUtils;
import com.google.common.base.Objects;
import com.google.common.base.Strings;

/**
 * 库（湖）站汛限水位表 Bean
 * 
 * @author XX
 * 
 */
public class RsvrfsrBean implements Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	// 站码
	private String stcd;
	// 启用年份
	private String actyr;
	// 开始年月
	private Date bgmd;
	// 结束年月
	private Date edmd;
	// 汛线水位
	private Double fsltdz;
	// 汛期类别
	private String fstp;

	public String getStcd() {
		return stcd;
	}

	public void setStcd(String stcd) {
		this.stcd = StringUtils.trim(stcd);
	}

	public String getActyr() {
		return actyr;
	}

	public void setActyr(String actyr) {
		this.actyr = StringUtils.trim(actyr);
	}

	public Date getBgmd() {
		return bgmd;
	}

	public void setBgmd(String bgmd) {
		this.bgmd = parseDate(bgmd);
	}

	public Date getEdmd() {
		return edmd;
	}

	public void setEdmd(String edmd) {
		this.edmd = parseDate(edmd);
	}

	public Double getFsltdz() {
		return fsltdz;
	}

	public void setFsltdz(Double fsltdz) {
		this.fsltdz = fsltdz;
	}

	public String getFstp() {
		return fstp;
	}

	public void setFstp(String fstp) {
		this.fstp = StringUtils.trim(fstp);
	}

	private Date parseDate(String dateStr) {
		if (Strings.isNullOrEmpty(dateStr))
			return null;
		// 101 表示1月1日，所以用Mdd 表示 1001 表示 10月01 日，所以用MMdd表示
		dateStr = StringUtils.trim(dateStr);
		String dateStrStyle = dateStr.length() == 3 ? "Mdd"
				: "MMdd";
		Date date = null;
		try {
			date = DateUtils.parseDate(dateStr, dateStrStyle);
		} catch (ParseException e) {
			e.printStackTrace();
		}
		return date;
	}

	@Override
	public int hashCode() {
		return Objects.hashCode(super.hashCode(), stcd, actyr, bgmd, edmd,
				fsltdz, fstp);
	}

	@Override
	public boolean equals(Object object) {
		if (object instanceof RsvrfsrBean) {
			if (!super.equals(object))
				return false;
			RsvrfsrBean that = (RsvrfsrBean) object;
			return Objects.equal(this.stcd, that.stcd)
					&& Objects.equal(this.actyr, that.actyr)
					&& Objects.equal(this.bgmd, that.bgmd)
					&& Objects.equal(this.edmd, that.edmd)
					&& Objects.equal(this.fsltdz, that.fsltdz)
					&& Objects.equal(this.fstp, that.fstp);
		}
		return false;
	}

	@Override
	public String toString() {
		return Objects.toStringHelper(this).add("super", super.toString())
				.add("serialVersionUID", serialVersionUID).add("stcd", stcd)
				.add("actyr", actyr).add("bgmd", bgmd).add("edmd", edmd)
				.add("fsltdz", fsltdz).add("fstp", fstp).toString();
	}

}
